package com.activities.api.data.providers;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

import com.activities.api.data.entities.Item;
import com.google.inject.Inject;

public abstract class StoreImpl<E extends Item> implements Store<E> {
	@Inject
	private EntityManagerFactory managerFactory;
	
	public EntityManagerFactory getManagerFactory() {
		return managerFactory;
	}

	public void setManagerFactory(EntityManagerFactory managerFactory) {
		this.managerFactory = managerFactory;
	}

	public EntityManager getManager() {
		EntityManagerFactory managerFactory = getManagerFactory();
		
		return managerFactory.createEntityManager();
	}
}
